package com.cskaoyan.shopping.service.impl;

import com.cskaoyan.shopping.converter.ContentConverter;
import com.cskaoyan.shopping.dal.entitys.PanelContent;
import com.cskaoyan.shopping.dal.persistence.PanelContentMapper;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.service.IContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author dinghongrui
 * @create 2022/09/20 23:59
 */
@Service
public class IContentServiceImpl implements IContentService {

    @Autowired
    PanelContentMapper panelContentMapper;

    @Autowired
    ContentConverter contentConverter;


    @Override
    public List<PanelContentDto> queryNavList() {
        Example example = new Example(PanelContent.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("panelId",0);
        List<PanelContent> panelContents = panelContentMapper.selectByExample(example);
        if (CollectionUtils.isEmpty(panelContents)) {
            return null;
        }
        List<PanelContentDto> panelContentDtoList = contentConverter.panelContents2Dto(panelContents);

        return panelContentDtoList;
    }
}
